<!-- 
All rights Reserved, Designed By www.youyacao.com 
@Description:卡密交易
@author:成都市一颗优雅草科技有限公司     
@version 松鼠聚合直播系统v2.0
注意：本前端源码遵循 MulanPSL-2.0开源协议（木兰宽松许可证）本内容仅限于个人参考，禁止用于其他的商业用途
需要商业用途或者定制开发等可访问songshu.youyacao.com   联系QQ:422108995 23625059584

 -->


<template>
    <div>
        <van-nav-bar
                title="转点给他人"
                left-text="返回"
                left-arrow
                fixed
                @click-left="onClickLeft"
        />
        <div style="padding-top: 56px;">
            <van-cell-group>
                <van-field
                        v-model="username"
                        label="对方账号"
                        placeholder="请输入对方账号 避免转错"
                />
                <van-field
                        v-model="userinfo.money"
                        label="剩余点数"
                        readonly
                        v-if="userinfo.user_type == 'daili'"
                />
                <van-field
                        v-model="money"
                        label="转出点数"
                        placeholder="0.00"
                />
                <div style="padding: 10px; text-align: center;color: red;">请核对账号，转错自负</div>
            </van-cell-group>
            <div style="padding: 30px 10px;"><van-button type="primary" size="large" style="height: 40px; line-height: 40px;" @click="dopaymoney()">确认转账</van-button></div>
        </div>
    </div>
</template>

<script>
    import global_ from '../Global';
    import { Toast } from 'vant';
    import { Notify } from 'vant';
    import { Dialog } from 'vant';
    export default {
        name: "paymoney",
        data(){
            return {
                userinfo:{},
                username:"",
                money:""
            }
        },
        created(){
          this.loadInfo();
        },
        methods:{
            onClickLeft:function () {
                this.$router.go(-1);
            },
            loadInfo:function () {
                this.$axios.get(global_.serverUrl+"admin/index/userinfo").then((res)=>{
                    if(res.code == 1){
                        this.userinfo = res.data;
                    }
                });
            },
            dopaymoney:function () {
                var that = this;
                var toast = Toast.loading({
                    mask: true,
                    duration: 0,
                    message: '提交中...'
                });
                this.$axios.post(global_.serverUrl+"admin/member/paymoney",{
                    paymoney:this.money,
                    username:this.username
                }).then((res)=>{
                    toast.clear();
                    if(res.code != 1){
                        Toast(res.msg);
                    }else{
                        Dialog.confirm({
                            title: '订单确认',
                            message: res.msg
                        }).then(() => {
                            toast = Toast.loading({
                                mask: true,
                                duration: 0,
                                message: '提交中...'
                            });
                            that.$axios.post(global_.serverUrl+"admin/member/dopaymoney",{
                                orderid:res.data
                            }).then((res2)=>{
                                toast.clear();
                                if(res2.code != 1){
                                    Toast(res2.msg);
                                }else{
                                    Notify({ type: 'success', message: '转点成功' });
                                    this.$router.replace("/");
                                }
                            }).catch(()=>{
                                toast.clear();
                            });
                        });
                    }
                }).catch(()=>{
                    toast.clear();
                });
            }
        }
    }
</script>

<style scoped>

</style>
